home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / 1.2 / scripts / title-header.scm.z / title-header.scm
Text File  |  2002-07-08  |  5KB  |  184 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Bump-mapped title script --- create a bump-mapped title image for web pages
  4. ; Copyright (C) 1997 Federico Mena Quintero
  5. ; federico@nuclecu.unam.mx
  6. ; ************************************************************************
  7. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  8. ; For use with GIMP 1.1.
  9. ;
  10. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  11. ; The call to gimp-palette-set-background has been given a real layer
  12. ; (although it is not used) otherwise gimp 1.1 crashed.
  13. ; ************************************************************************
  14. ; This program is free software; you can redistribute it and/or modify
  15. ; it under the terms of the GNU General Public License as published by
  16. ; the Free Software Foundation; either version 2 of the License, or
  17. ; (at your option) any later version.
  18. ; This program is distributed in the hope that it will be useful,
  19. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ; GNU General Public License for more details.
  22. ; You should have received a copy of the GNU General Public License
  23. ; along with this program; if not, write to the Free Software
  24. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26.  
  27. (define (script-fu-title-header text
  28.                 size
  29. ;                foundry
  30. ;                family
  31. ;                weight
  32. ;                slant
  33. ;                set-width
  34.                 fontname)
  35.   (let* (; Parameters
  36.      
  37.      (padding 8)
  38.      (fade-width 64)
  39.      
  40.      ; Save foreground and background colors
  41.  
  42.      (old-fg-color (car (gimp-palette-get-foreground)))
  43.      (old-bg-color (car (gimp-palette-get-background)))
  44.      
  45.      ; Image 
  46.  
  47.      (img (car (gimp-image-new 256 256 RGB)))
  48.  
  49.      ; Text layer
  50.      
  51.      (text-layer (car (gimp-text-fontname
  52.                img
  53.                -1
  54.                0
  55.                0
  56.                text
  57.                padding
  58.                TRUE
  59.                size
  60.                PIXELS
  61.                fontname)))
  62.      (text-width (car (gimp-drawable-width text-layer)))
  63.      (text-height (car (gimp-drawable-height text-layer)))
  64.  
  65.      ; Sizes
  66.  
  67.      (text-layers-offset (/ text-height 2))
  68.  
  69.      (img-width (+ text-layers-offset text-width fade-width))
  70.      (img-height text-height)
  71.  
  72.      ; Additional layers
  73.      
  74.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "bg-layer" 100 NORMAL)))
  75.      (bumpmap-layer (car (gimp-layer-new img
  76.                          text-width
  77.                          text-height
  78.                          RGBA_IMAGE
  79.                          "bumpmap-layer"
  80.                          100
  81.                          NORMAL)))
  82.      (fore-layer (car (gimp-layer-new img text-width text-height RGBA_IMAGE "fore-layer" 100 NORMAL))))
  83.     
  84.     ; Create image
  85.     
  86.     (gimp-image-undo-disable img)
  87.     (gimp-image-resize img img-width img-height 0 0)
  88.     
  89.     (gimp-image-add-layer img bg-layer -1)
  90.     (gimp-image-add-layer img bumpmap-layer -1)
  91.     (gimp-image-add-layer img fore-layer -1)
  92. ;    (gimp-image-add-layer img text-layer -1)
  93.     (gimp-image-raise-layer img text-layer)
  94.     (gimp-image-raise-layer img text-layer)
  95.     (gimp-image-raise-layer img text-layer)
  96.     (gimp-layer-set-offsets bg-layer 0 0)
  97.     (gimp-layer-set-offsets text-layer text-layers-offset 0)
  98.     (gimp-layer-set-offsets bumpmap-layer text-layers-offset 0)
  99.     (gimp-layer-set-offsets fore-layer text-layers-offset 0)
  100.  
  101.     ; Create bumpmap layer
  102.  
  103.     (gimp-palette-set-background '(0 0 0))
  104.     (gimp-edit-fill bumpmap-layer BG-IMAGE-FILL)
  105.     (gimp-selection-layer-alpha text-layer)
  106.     (gimp-palette-set-background '(255 255 255))
  107.     (gimp-edit-fill bumpmap-layer BG-IMAGE-FILL)
  108.     (gimp-selection-none img)
  109.     (plug-in-gauss-rle 1 img bumpmap-layer 4.0 TRUE TRUE)
  110.  
  111.     ; Fore layer, bumpmap
  112.  
  113.     (gimp-palette-set-background '(255 255 255))
  114.     (gimp-edit-fill fore-layer BG-IMAGE-FILL)
  115.     (plug-in-bump-map 1 img fore-layer bumpmap-layer 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  116.  
  117.     ; Text layer
  118.  
  119.     (gimp-layer-set-visible text-layer TRUE)
  120.     (gimp-layer-set-preserve-trans text-layer TRUE)
  121.     (gimp-blend text-layer CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0.2 3
  122.         padding
  123.         padding
  124.         (- text-width padding 1)
  125.         (- text-height padding 1))
  126.  
  127.     ; Semicircle at the left
  128.  
  129.     (gimp-palette-set-background '(0 0 0))
  130.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  131.     
  132.     (gimp-ellipse-select img 0 0 text-height text-height REPLACE TRUE FALSE 0)
  133.     (gimp-palette-set-background (car (gimp-color-picker img text-layer text-layers-offset 0 TRUE FALSE 0 0)))
  134.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  135.  
  136.     ; Fade-out gradient at the right
  137.  
  138.     (gimp-rect-select img (- img-width fade-width) 0 fade-width text-height REPLACE FALSE 0)
  139.     (gimp-palette-set-foreground (car (gimp-palette-get-background)))
  140.     (gimp-palette-set-background '(0 0 0))
  141.     (gimp-blend bg-layer
  142.         FG-BG-RGB
  143.         NORMAL
  144.         LINEAR
  145.         100
  146.         0
  147.         REPEAT-NONE
  148.         FALSE
  149.         0.2
  150.         3
  151.         (- img-width fade-width)
  152.         0
  153.         (- img-width 1)
  154.         0)
  155.     (gimp-selection-none img)
  156.  
  157.     ; Done
  158.     
  159. ;    (gimp-image-flatten img)
  160.     (gimp-palette-set-foreground old-fg-color)
  161.     (gimp-palette-set-background old-bg-color)
  162.     (gimp-image-undo-enable img)
  163.     (gimp-display-new img)))
  164.  
  165. (script-fu-register "script-fu-title-header"
  166.             _"<Toolbox>/Xtns/Script-Fu/Logos/Web Title Header..."
  167.             "Web title header"
  168.             "Federico Mena Quintero"
  169.             "Federico Mena Quintero"
  170.             "June 1997"
  171.             ""
  172.             SF-STRING     _"Text" "Hello world!"
  173.             SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 256 1 10 0 0)
  174.             SF-FONT       _"Font" "-adobe-helvetica-bold-r-normal-*-30-*-*-*-p-*-*-*")
  175.  
  176.  
  177.  
  178.  
  179.  
  180.